﻿@model ProductOverviewModel
@using Nop.Core
@using Nop.Core.Domain.Orders
@using Nop.Core.Domain.Tax
@using Nop.Core.Infrastructure
@using Nop.Web.Extensions
@using Nop.Web.Models.Catalog;



@helper Price_Modifier(string input, int length) 
{
    if(input.Length<= length)
    {
       @Html.Raw(@input)
    }
    else
    {
        @Html.Raw(@input.Substring(0,length))<text>...</text>
    }


}

@{
    //prepare "Add to cart" AJAX link
    string addtocartlink = "";
    var shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart;
    var quantity = 1;
    if (Model.ProductPrice.ForceRedirectionAfterAddingToCart)
    {
        addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart });
    }
    else
    {
        addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, });
    }    
}
<div class="product-item" data-productid="@Model.Id">
<div class="white-box">
    <div class="picture thumbnail">
        <a href="@Url.RouteUrl("Product", new { SeName = Model.SeName })" title="@Model.DefaultPictureModel.Title">
            <img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.DefaultPictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title" />
        </a>
        
       @* <a href="javascript:void(0)" onclick="displayBootstrapModal('@Model.Id')" class="btn btn-default fa fa-search" > Quick View</a>*@
    </div>
    
    
    <div class="middle-content">
        <h2 class="product-title">
            <a href="@Url.RouteUrl("Product", new
                                                  {
                                                      SeName = Model.SeName
                                                  })"> @Model.Name</a>
        </h2>
        @if(Model.ReviewOverviewModel.AllowCustomerReviews)
        {
            int ratingPercent = 0;
            if(Model.ReviewOverviewModel.TotalReviews != 0)
            {
                ratingPercent = ((Model.ReviewOverviewModel.RatingSum * 100) / Model.ReviewOverviewModel.TotalReviews) / 5;
            }
            <div class="product-rating-box" title="@string.Format(T("Reviews.TotalReviews").Text, Model.ReviewOverviewModel.TotalReviews)">
                <div class="rating">
                    <div style="width: @(ratingPercent)%">
                    </div>
                </div>
            </div>
        }
        <div class="description">
            @if(!String.IsNullOrEmpty(Model.ShortDescription))
            {
                @Model.ShortDescription
            }
            
            @*@Html.Raw(Model.ShortDescription)*@
        </div>
    </div>
</div>
    <div class="add-info">
			<div class="ash-box">
				
            @if (!String.IsNullOrEmpty(Model.ProductPrice.OldPrice)|| Model.ProductPrice.DisplayTaxShippingInfo)
            {
							<div class="prices">
								@if (!String.IsNullOrEmpty(Model.ProductPrice.OldPrice))
								{
									<span class="price old-price">@Model.ProductPrice.OldPrice</span>
								}
								
								<span class="price actual-price">@Model.ProductPrice.Price</span>
								@if (Model.ProductPrice.DisplayTaxShippingInfo)
								{
									var inclTax = EngineContext.Current.Resolve<IWorkContext>().TaxDisplayType == TaxDisplayType.IncludingTax;
									//tax info is already included in the price (incl/excl tax). that's why we display only shipping info here
									//of course, you can modify appropriate locales to include VAT info there
									<div class="tax-shipping-info">
										@T(inclTax ? "Products.Price.TaxShipping.InclTax" : "Products.Price.TaxShipping.ExclTax", Url.RouteUrl("Topic", new { SeName = Html.GetTopicSeName("shippinginfo") }))
									</div>
								}
							</div>

            }else
						{
                            <div class="new-prices">
								
								<span class="price actual-price">@Model.ProductPrice.Price</span>
							</div>
						}

				@*<div class="prices">
					@if (!String.IsNullOrEmpty(Model.ProductPrice.OldPrice))
					{
						<span class="price old-price">@Model.ProductPrice.OldPrice</span>
					}
					<span class="price actual-price">@Model.ProductPrice.Price</span>
					@if (Model.ProductPrice.DisplayTaxShippingInfo)
					{
						var inclTax = EngineContext.Current.Resolve<IWorkContext>().TaxDisplayType == TaxDisplayType.IncludingTax;
						//tax info is already included in the price (incl/excl tax). that's why we display only shipping info here
						//of course, you can modify appropriate locales to include VAT info there
						<div class="tax-shipping-info">
							@T(inclTax ? "Products.Price.TaxShipping.InclTax" : "Products.Price.TaxShipping.ExclTax", Url.RouteUrl("Topic", new { SeName = Html.GetTopicSeName("shippinginfo") }))
						</div>
					}
				</div>*@
				<div class="buttons">
					@*<input type="button" value="@T("Products.Details")" class="button-1 product-box-detail-button" onclick="setLocation('@Url.RouteUrl("Product", new { SeName = Model.SeName })')" />*@
					@if (!Model.ProductPrice.DisableBuyButton)
					{
                        <input type="button" class="btn btn-sm btn-default" value="@(Model.ProductPrice.AvailableForPreOrder ? T("ShoppingCart.PreOrder") : T("ShoppingCart.AddToCart"))" class="button-2 product-box-add-to-cart-button" onclick="AjaxCart.addproducttocart_catalog('@addtocartlink    ');return false;" />

					}
				</div>
				@Html.Widget("productbox_add_info")
			</div>
    </div>
    
        
</div>


<script>
    $(document).ready(function(){
        $(".product-item .middle-content .product-title").ellipsis();
        $(".product-item .middle-content .description").ellipsis();
    });
</script>